---
description: "Reference for Nitric's v0 .NET library - Creates a reference to a secret in the secrets manager."
---

# .NET - Secret()

Creates a reference to a secret in the secrets manager.

```csharp
using Nitric.Sdk;
using Nitric.Sdk.Resource;

var keyRef = Nitric.Secret("apiKey").With(SecretPermission.Accessing);

Nitric.Run();
```

## Parameters

<Properties>
  <Property name="name" required type="string">
    The unique name of this secret within the secrets manager.
  </Property>
</Properties>

## Access

All Nitric resources provide access permissions you can use to specify the level of access your code needs to the resource. See here for details about infrastructure [security](/get-started/foundations/infrastructure/security).

### Available permissions:

---

**SecretPermission.Putting**

This permission allows your code to set a new latest value for a secret.

---

**SecretPermission.Accessing**

This permission allows your code to retrieve secret values.

---

## Examples

### Create a reference to a secret

```csharp
using Nitric.Sdk;
using Nitric.Sdk.Resource;

var keyRef = Nitric.Secret("apiKey").With(SecretPermission.Putting);

Nitric.Run();
```

### See also

- [Secret.Put()](./secret-put)
- [Secret.Version()](./secret-version)
- [Secret.Latest()](./secret-latest)
- [Secret.Version.Access()](./secret-version-access)
